﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Net.Sockets;

namespace C4F.DevKit.Bluetooth
{
    namespace ServiceAndDeviceDiscovery
    {
        /// <summary>
        /// Defines the Connection Event Arguments for the Connected Event.
        /// </summary>
        public class ConnectionEventArgs : AsyncCompletedEventArgs
        {
            #region Private Members
            /// <summary>
            /// Represents a network stream for communication with remote 
            /// service.
            /// </summary>
            private NetworkStream servStream;
            #endregion

            #region Public Property
            /// <summary>
            /// Gets the service stream.
            /// </summary>
            public NetworkStream ServiceStream
            {
                get
                {
                    RaiseExceptionIfNecessary();
                    return this.servStream;
                }
            }
            #endregion

            #region Constructor

            /// <summary>
            /// Initializes the ConnectionEventArgs object.
            /// </summary>
            /// <param name="serviceStream">Network Stream used for 
            /// communication with remote service.</param>
            /// <param name="e">An error that occurred during the 
            /// asynchronous operation.</param>
            /// <param name="canceled">A value indicating whether the 
            /// asynchronous operation was cancelled.</param>
            /// <param name="state">The user-supplied state object supplied
            /// when the asynchronous operation was requested.</param>

            public ConnectionEventArgs(NetworkStream serviceStream,
                                       Exception e,
                                       bool canceled,
                                       object state)

                : base(e, canceled, state)
            {
                this.servStream = serviceStream;
            }
            #endregion

        }
    }
}